package com.dxd.servlet.swzl;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.dxd.constant.ErrorCodeConstant;
import com.dxd.entity.MessageType;
import com.dxd.entity.ReturnBean;
import com.dxd.servlet.PublicServlet;

/**
 * 前端类型管理
 * 
 * @author pppcar
 *
 */
@WebServlet("/swzl/messageType")
public class MessageTypeServlet extends PublicServlet {

	private static final long serialVersionUID = -2754603844053914575L;
	private static final Logger LOG = LoggerFactory.getLogger(MessageTypeServlet.class);

	protected void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		String type = request.getParameter("type");
		LOG.info("/swzl/messageType:{}", type);

		if ("queryByParentId".equals(type)) {

			ReturnBean returnBean = ReturnBean.returnBeanBuild();
			String parentId = request.getParameter("parentId");
			if (parentId == null || "".equals(parentId)) {
				returnBean.setReturnCode(ErrorCodeConstant.PARAM).setReturnMsg("消息类型id为空");
				returnJson(returnBean);
				return;
			}
			List<MessageType> messageTypes = messageTypeDao.queryList(Integer.parseInt(parentId));
			returnBean.setReturnMsg("查询成功").setData(messageTypes);
			returnJson(returnBean);
			return;

		}
	}

}